Install a Custom Helm Chart

Learn how to configure and install a custom Helm chart.

Configure front-end and back-end services#

To make use of the Helm chart that has been just built we need to provide some values, e.g., a Docker image name and a tag. So, let’s define YAML files for the frontend and backend.

First, let’s do it for a front-end application by creating a separate /kanban-frontend.yaml file, as follows:

The kanban-frontend.yaml file

As we can see, we’re keeping an initial structure of properties from values.yaml and overriding only those values that are needed, like the most important one—Docker image— which is wkrzywiec/kanban-ui.

For a back-end application we need an analogous thing, so we create a /kanban-backend.yaml file, as below:

The kanban-backend.yaml file

This is very similar, but this time we also want to inject environment variables that are necessary for back-end applications to make a connection with a PostgreSQL database.

Having both files defined we can now move on to the next step, which is installing both Helm releases.

Install and verify a custom Helm chart#

To run a back-end service of a Kanban application, first we would need to have a Postgres database in which we can store data about boards and a list of tasks. We can either try to find cheap hosting for that or manually install it locally, but luckily for us, we know Helm and we know that there is a free-to-use Helm chart which we can use to install the PostgreSQL database on our cluster.

The first step is to add the Helm repository so that we’ll be able to download the proper Helm chart:

Adding the Bitnami Helm repository

The output will be as follows:

"bitnami" has been added to your repositories

We can now proceed with installing it, but before that, let’s configure it a little bit. In the same folder where kanban-frontend.yaml and kanban-backend.yaml files are located, create a new one, /postgres.yaml, as given below:

The postgres.yaml file with configuration for PostgreSQL

With the above configuration, we’re making sure that the full name of the resulting Kubernetes resources will be postgres, Docker containers will be based on the 11.14.0-debian-10-r17 Docker image, and during the first start-up, a kanban database and user will be created.

Once we have it, we can create the postgres release in a new kanban namespace:

Installing PostgreSQL on a cluster

The output will be as follows:

Release "postgres" does not exist. Installing it now.
NAME: postgres
LAST DEPLOYED: Thu Mar 23 05:52:09 2023
NAMESPACE: kanban
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: postgresql
CHART VERSION: 12.1.6
APP VERSION: 15.1.0

** Please be patient while the chart is being deployed **

PostgreSQL can be accessed via port 5432 on the following DNS names from within your cluster:

    postgres.kanban.svc.cluster.local - Read/Write connection

To get the password for "postgres" run:

    export POSTGRES_ADMIN_PASSWORD=$(kubectl get secret --namespace kanban postgres -o jsonpath="{.data.postgres-password}" | base64 -d)

To get the password for "kanban" run:

    export POSTGRES_PASSWORD=$(kubectl get secret --namespace kanban postgres -o jsonpath="{.data.password}" | base64 -d)

To connect to your database run the following command:

    kubectl run postgres-client --rm --tty ---restart='Never' --namespace kanban --image docker.io/bitnami/postgresql:11.14.0-debian-10-r17 --env="PGPASSWORD=$POSTGRES_PASSWORD" \
      --command -- psql --host postgres -U kanban -d kanban -5432

    > NOTE: If you access the container using bash, make sure that you execute "/opt/bitnami/scripts/postgresql/entrypoint.sh /bin/bash" in order to avoid the error "psql: local user with ID 1001} does not exist"

To connect to your database from outside the cluster execute the following commands:

    kubectl port-forward --namespace kanban svc/postgres 5432:5432 &
    PGPASSWORD="$POSTGRES_PASSWORD" psql --host 127.0.0.1 -U kanban -d kanban -5432

For a short while, it will continue installing and will ultimately result in a fully operational database. Setting up a database was never that easy!

Now, we can proceed with installing a back-end Service for a Kanban application, so let’s run a command:

Installing a Kanban back-end Service on a cluster

The output will be as follows:

Release "kanban-backend" does not exist. Installing it now.
NAME: kanban-backend
LAST DEPLOYED: Tue Dec 14 06:45:14 2021
NAMESPACE: kanban
STATUS: deployed
REVISION: 1
TEST SUITE: None

Great! We can validate if it’s working by listing the Pods in the kanban namespace:

Listing all the Pods

The output will be as follows:

NAME                              READY   STATUS    RESTARTS   AGE
kanban-backend-6bbbc966d6-8v5vd   1/1     Running   0          70s
postgres-0                        1/1     Running   0          2m1s

A status is okay, so we can go on with installing the front-end Service:

Installing a Kanban front-end Service on a cluster

The output will be as follows:

Release "kanban-frontend" does not exist. Installing it now.
NAME: kanban-frontend
LAST DEPLOYED: Tue Dec 14 06:52:02 2021
NAMESPACE: kanban
STATUS: deployed
REVISION: 1
TEST SUITE: None

Again, to investigate if the Pod is up and running, let’s use a kubectl command:

Listing all the Pods

Here is what the output will be:

NAME                               READY   STATUS    RESTARTS   AGE
kanban-backend-6bbbc966d6-8v5vd    1/1     Running   0          25m
kanban-frontend-7b54467f96-bxf48   1/1     Running   0          3m14s
postgres-0                         1/1     Running   0          26m
/
kanban-backend.yaml
postgres.yaml
kanban-frontend.yaml
app
Playground for installing Kanban Helm chart

And now the tricky part: how to get into a Kanban front-end Service? For now, we’ll proceed with a port forwarding approach.

Note: If you’re using the playground above, the only thing to do is to run the following command in a terminal: kubectl proxy --address 0.0.0.0 --accept-hosts='.*' and then enter the app URL.

To achieve this we’ll be using the kanban-frontend Service (we can find it with the kubectl get svc -n kanban command) and we’ll map a local 8081 port with an 8080 port of a Service deployed in a cluster:

The port forward kanban-frontend Service

The output will be as follows:

Forwarding from 127.0.0.1:8081 -> 80
Forwarding from [::1]:8081 -> 80

Now, if we enter http://localhost:8081, we should be able to see the main page of a Kanban board, as shown below:

The main page of a Kanban board front-end application
The main page of a Kanban board front-end application

And that’s it! We’ve created and installed a fully operational Helm chart!

Create a Simple Helm Chart

Introduction to Named Templates